<template>
  <div style="padding: 24px">
    <div class="classification">
      <el-card class="classification-card" v-for="item in classificationList" :key="item.id"
               :body-style="{ padding: '0px' }"
               style="width: 300px;"
               shadow="hover"
      >
        <template #header>
          <h1 style="text-align: center">{{ item.name }}</h1>
        </template>
        <el-image :src="item.coverUrl" style="width: 300px"/>
        <div style="padding: 14px">
          <span>{{item.summarize}}</span>
        </div>
        <div style="display: flex; flex-direction: row-reverse; padding: 5px 14px">
          <el-button link>文章总数：{{ item.totalArticle }}</el-button>
          <el-button link>浏览量：{{ item.viewsNo }}</el-button>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
import { classificationList } from '@/api/classification'

export default {
  name: 'article-classification',
  setup () {
    return {
      classificationList: ref([])
    }
  },
  methods: {
    getList () {
      classificationList().then(value => {
        this.classificationList = value.data
      })
    }
  },
  mounted () {
    this.getList()
  }
}
</script>

<style scoped>
.classification{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap; /* 换行 */
  /*column-fill: balance;*/
}
.classification:after{
  content: '';
  flex: auto;
}
.classification .classification-card{
  margin: 58px;
}
</style>
